set proc to sospro
set proc to boxproc
dr='q:'
f1='revenue2'
f11='revemp2'
sele 1
set exclu off
use &dr&f1 inde &dr&f11
go top
SET DEVI TO PRINT
@ 0, 1 SAY CMONTH(DATE()-25)+' '+STR(YEAR(DATE()-25))
@ 0, 1 SAY '                                 HEALTHLINE PATIENT'
@ 2, 1 say 'PATIENT  PATIENT NAME                 TOTAL       TOTAL       TOTAL      TOTAL'
@ 3, 1 SAY ' CODE                             PROCEDURE    PHARMACY         PAY         HL'
@ 4, 1 SAY '=============================================================================='
BR=5
Gtotproc=0
Gtotphar=0
Gtotfee=0
GTOTVIS=0
TOTHL=0
GTOTHL=0
do while .not. eof()
   codtyp=pat_codtyp

*   if codtyp<>'9' .and. codtyp<>'0'
*      skip
*      loop
*   endif

   IF .NOT. HEALTHLINE
      SKIP
      LOOP
   ENDIF
   patkod=pat_filcod
   patnam=pat_name
   patfnam=pat_f_name
   totproc=0
   totphar=0
   totFEE=0
   TOTHL=0
   do while patkod=pat_filcod .and. .not. eof()

*      if codtyp<>'9'.and. codtyp<>'0'
*         skip
*         loop
*      endif
      IF .NOT. HEALTHLINE
         SKIP
         LOOP
      ENDIF


      totproc=totproc+total_proc
      totphar=totphar+total_phar
      totfee =totfee +total_PAY
      TOTHL=TOTHL+TOTAL_HL
      Gtotproc=Gtotproc+total_proc
      Gtotphar=Gtotphar+total_phar
      Gtotfee =Gtotfee +total_PAY
      GTOTHL=GTOTHL+TOTAL_HL
      skip
   enddo
   @ br,2 say patkod
   @ br,10 say alltrim(patnam)+' '+alltrim(patfnam)
   DO SAYG WITH BR,34,TOTPROC,'999,999.99','99,999,999'
   DO SAYG WITH BR,46,TOTPHAR,'999,999.99','99,999,999'
   DO SAYG WITH BR,58,TOTFEE,'999,999.99','99,999,999'
   DO SAYG WITH BR,69,TOTHL,'999,999.99','99,999,999'
*   @ br,34 say totproc pict '99,999,999'
*   @ br,46 say totphar pict '99,999,999'
*   @ br,58 say totfee pict '99,999,999'
*   @ BR,69 SAY TOTHL PICT '99,999,999'
   br=br+1
   if br=56
      @ 0, 1 SAY CMONTH(DATE()-25)+' '+STR(YEAR(DATE()-25))
      @ 0, 1 SAY '                                 HEALTHLINE PATIENT'
      @ 2, 1 say 'PATIENT  PATIENT NAME                 TOTAL       TOTAL       TOTAL      TOTAL'
      @ 3, 1 SAY ' CODE                             PROCEDURE    PHARMACY         PAY         HL'
      @ 4, 1 SAY '=============================================================================='
      BR=5
   ENDIF
enddo
BR=BR+1
DO SAYG WITH BR,34,GTOTPROC,'999,999.99','99,999,999'
DO SAYG WITH BR,46,GTOTPHAR,'999,999.99','99,999,999'
DO SAYG WITH BR,58,GTOTFEE,'999,999.99','99,999,999'
DO SAYG WITH BR,69,GTOTHL,'999,999.99','99,999,999'
*@ br,34 say Gtotproc pict '99,999,999'
*@ br,46 say Gtotphar pict '99,999,999'
*@ br,58 say Gtotfee pict '99,999,999'
*@ BR,69 SAY GTOTHL PICT '99,999,999'

CLOS ALL
SET DEVI TO SCREEN

